package com.chris.design.pattern.samples.chain.demo;

import java.util.Objects;

/**
 * 部门经理 handler
 */
public class DeptManager extends AbstractHandler {


    /**
     * 申请聚餐的业务逻辑处理方法
     *
     * @param user
     * @param fee
     * @return
     */
    @Override
    public String handleFeeRequest(String user, int fee) {
        String msg = "";
        if (fee > 500 && fee <= 1000) {
            if (Objects.equals(DeptManager.class.getSimpleName(), user)) {
                msg = "成功：部门经理同意【" + user + "】的聚餐费用，金额为" + fee + "元";
            } else {
                msg = "失败：部门经理不同意【" + user + "】的聚餐费用，金额为" + fee + "元";
            }
        } else if (fee > 1000) {
            if (getHandler() != null) {
                getHandler().handleFeeRequest(user, fee);
            }
        }

        return msg;
    }
}
